<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=8">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta content="B2B电商平台" name="description" />
		<meta content="B2B电商平台" name="keyword" />

		<title></title>
		<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/global.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/pro.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/proManage.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css"></link>
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
		<script type="text/javascript" src="<%=path%>/include/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/cookies.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/icss.busin.js"></script>
		<script type="text/javascript" src="<%=path%>/include/JQuery ui/js/jquery-ui-1.7.3.custom.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/icss.common.js"></script>
		<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
		<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/jquery.print.js"></script>
		<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
		<style type="text/css">
			.table tr td {
				border-left: 1px solid #000;
				border-bottom: 1px solid #000;
				height: 33px;
				text-align: center;
			}
			.bor_css{ border-top: 1px solid #000;}
			.bor_css1{ border-right: 1px solid #000;}
			.tab_css{ border:0px; width: 100%;}
			.tab_css tr td{ border:0px;text-align: left;padding-left: 20px !important;color: #000;}
			
			.table tr th {
				border-left: 1px solid #000;
				font-weight: bold;
			}
			em.create {
			    background-position: -50px -44px;
			    line-height: 28px;
			    display: inline-block;
			    font-style: normal;
			    background-repeat: no-repeat;
			    text-indent: 15px;
			    float: right;
			    cursor: pointer;
			}
			.create {
				background: url("<%=path%>/images/coupons/sort_zss.png");
			}
			
			#queryId button{
				background-image: url("<%=path%>/include/css/img/xs_bgx.png");
			    background-color: transparent;
			}
			.cxx_btn{
				width: 44px;
			    height: 24px;
			    background-position: 0px -203px;
			    line-height: 24px;
			    margin: 0px 0px 0px 5px;
			}
			a{
				color: #039;
			}
			#tbody td{
			padding: 0px 4px;
			vertical-align: middle;
			font-size: 12px;
			}
		</style>
		<script type="text/javascript">
	$(function(){
		_search();
	});

	var pagination;
	function _search() {
		var orderStatus = $("#orderStatus").val();
	 	var stime = $("#stime").val();
		var etime = $("#etime").val();
		if(stime>etime){
			parent.swal("开始时间不大于结束时间");
			return;
		}
		var url = "<%=path%>/orderList/queryOrderPrintList.do";
		var data = {
				orderStatus:orderStatus,
				stime:stime,
				etime:etime
		};
		pagination = _initPagination({'pageId':'pagination','cKey':'orderList', 'url': url, 'data': data, 'rows': 10, 'callback':_initDataList});
	}
	
	function _initDataList(data) {
 		var d = data.rows;
 		var total = data.total;
 		var html = "";
 		$('#tbody').empty();
 		if(d.length>0){
 	 		var dateStr = $("#dateStr").val();
			for(var i=0;i<d.length;i++){
				html += "<tr class='bor_css1'>";
				html += "	<td colspan='2' class='bor_css' style='font-size: 20px;height:80px;'>徽映优选</td>";
				var v1 = "下单时间："+d[i].CREATE_TIME+"&nbsp;&nbsp;收货人："+d[i].USER_NAME+"&nbsp;&nbsp;收货电话："+d[i].CON_TEL+"&nbsp;&nbsp;收货地址："+
					d[i].PROVINCE+d[i].CITY+d[i].COUNTY+"  备注："+d[i].ORDER_STATUS_NODE;
				html += "	<td colspan='6' class='bor_css' style='text-align: left;border-left:0px;'>"+v1+"</td>";
				html += "</tr>";
				html += "<tr class='bor_css1'><td style='width:6%'>序号</td><td style='width:21%'>商品名称</td><td style='width:12%'>规格</td><td style='width:16%'>条码</td><td style='width:16%'>优惠信息</td><td style='width:10%'>单价</td><td style='width:10%'>数量</td><td style='width:10%'>小计</td></tr>";
				var yhxx = d[i].YHXX;
    			var yhStr = "";
    			if(yhxx!=null&&""!=yhxx){
    				if(yhxx.indexOf(";")>0){
    					var yhArr = yhxx.split(";");
    					for(var ii=0;ii<yhArr.length;ii++){
    						yhStr += (ii+1)+"、"+yhArr[ii]+";  ";
    					}
    				}else{
    					yhStr += "1、"+yhxx+";  ";
    				}
    			}
				var products = d[i].products;
				var proNum = 0;
				var proPrice = 0.00;
				for(var j=0;j<products.length;j++){
					var pro = products[j];
					html += "<tr class='bor_css1'>";
					html += "	<td>"+(j+1)+"</td>";
					html += "	<td>"+pro.PRODUCT_NAME+"</td>";
					html += "	<td>"+pro.PARAM_VALUE+"</td>";
					html += "	<td>"+pro.BAR_CODE+"</td>";
					if(j==0) html += "<td  rowspan='"+products.length+"'>"+yhStr+"</td>";
					html += "	<td>"+pro.PRODUCT_PRICE+"</td>";
					html += "	<td>"+pro.SELL_AMOUNT+"</td>";
					html += "	<td>"+(parseInt(pro.PRODUCT_PRICE)*parseFloat(pro.SELL_AMOUNT))+"</td>";
					html += "</tr>";
					proNum += parseInt(pro.SELL_AMOUNT);
					proPrice += (parseInt(pro.PRODUCT_PRICE)*parseFloat(pro.SELL_AMOUNT));
				}
				var yhPrice = parseFloat(d[i].SUM_SELL_MONEY)-parseFloat(d[i].SUM_REAL_MONEY);
				var v2 = "<table class='tab_css'><tr><td>货款："+d[i].SUM_SELL_MONEY+"</td><td>优惠："+yhPrice+"</td><td>应付款："+d[i].SUM_REAL_MONEY+"</td><td>已付款："+d[i].PAY_MONEY+"</td></tr></table>";
				html += "<tr class='bor_css1'>";
				html += "	<td colspan='4'>"+v2+"</td>";
				var payOnline = d[i].PAY_ONLINE;
				var payType = payOnline == "1" ? "在线支付" : "货到付款";
				html += "	<td colspan='2' style='font-size: 20px;'>"+payType+"</td>";
				html += "	<td>"+proNum+"</td>";
				html += "	<td>"+proPrice+"</td>";
				html += "</tr>";
				var v3 = "<table class='tab_css'><tr><td>供货商："+d[i].SHOP_NAME+"</td><td>供货商电话："+d[i].SHOP_TEL+"</td><td>地址："+d[i].SHOP_ADDRESS+"</td></tr></table>";
				html += "<tr class='bor_css1'>";
				html += "	<td colspan='8' style='text-align: left'>"+v3+"</td>";
				html += "</tr>";
				var v4 = "<table class='tab_css'><tr><td>送货员：</td><td>送货时间：</td><td>超市签字（我确认已收到相应货品）：</td></tr></table>";
				html += "<tr class='bor_css1'>";
				html += "	<td colspan='8' style='text-align: left'>"+v4+"</td>";
				html += "</tr>";
				var v5 = "<table class='tab_css'><tr><td>超市进货&nbsp;&nbsp;徽映优选（www.jiefangyx.com）</td><td>订单打印时间："+dateStr+"</td></tr></table>";
				html += "<tr class='bor_css1'>";
				html += "	<td colspan='8' style='text-align: left'>"+v5+"</td>";
				html += "</tr>";
				
				html += "<tr>";
				html += "	<td colspan='8' style='text-align: left;border:0px;height:60px;'></td>";
				html += "</tr>";
			}
 		}
		$('#tbody').html(html);
		_reHeight("rightFrame","contentDiv");
	}	
	function _clear(){
		$("#stime").val("");
		$("#etime").val("");
	}
</script>
	</head>

	<body style="font-family: '微软雅黑';">
		<div id="contentDiv" style="padding:4px; width:99%;">
			<div class="colnums-2-ab-b">
				<div class="toptil" >订单信息打印列表</div>
				<div></div>
				<input id="orderStatus" name="orderStatus" value="${orderStatus }" type="hidden"/>
				<input id="dateStr" name="dateStr" value="${dateStr }" type="hidden"/>
				<div  id="queryId" style="border: 2px solid #e0e0e0;background: #f5f5f5;padding-left:10px;margin-bottom:10px;height: 40px;;line-height: 40px;font-size:14px;">
					开始时间：<input type="text" id="stime" name="stime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" 
							    	style="width: 100px;height: 24px; padding-left: 3px" onfocus="WdatePicker({position:{left:84,top:86}})" class="Wdate" value="${stime }"/>
					至<input type="text" id="etime" name="etime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" 
							    	style="width: 100px;height: 24px; padding-left: 3px" onfocus="WdatePicker({position:{left:203,top:86}})" class="Wdate" value="${etime }"/>
					<button class="cxx_btn" type="button" onclick="_search()">查询</button>
					<button class="cxx_btn" type="button" onclick="_clear()">清空</button>
					<button class="cxx_btn" type="button" onclick="$('#listTable').print()">打印</button>
				</div>
				<div class="row-fluid dataTables_wrapper">
					
					<table id="listTable" class="table table-hover table-nomargin table-bordered usertable dataTable"
						style="width: 100%; border-spacing: 0;font-weight:bold;font-size:9pt;color: #000;">
						<tbody id="tbody" style="font-size: 14px">
						</tbody>
					</table>
					<div class="dataTables_paginate paging_full_numbers">
						<span id="innerHtml"> </span>
					</div>
					<div id="pagination"></div>
					<div>
						<div style="height: 30px;"></div>
						<!-- 分类列表div结束 -->
						<div class="clear"></div>
					</div>
				</div>
				</div>
			</div>
	</body>
	<script type="text/javascript">
	$(document).ready(function(){
			_reHeight("rightFrame","contentDiv");
	 });
</script>
</html>
